(C) 1996 AROS - The Amiga Replacement OS


NAME
void qsort()
SYNOPSIS
void * a
size_t n
size_t es
int (* cmp(const void * const void *

FUNCTION
Sort the array a. It contains n elements of the size es. Elements are compares using the function cmp().

INPUTS
a
The array to sort
n
The number of elements in the array
es
The size of a single element in the array
cmp
The function which is called when two elements must be compared. The function gets the addresses of two elements of the array and must return 0 is both are equal, < 0 if the first element is less than the second and > 0 otherwise.
RESULT
None.

NOTES
EXAMPLE
// Use this function to compare to stringpointers
int cmp_strptr (const char ** sptr1, const char ** sptr2)
{
    return strcmp (*sptr1, *sptr2);
}

// Sort an array of strings
char ** strings;

// fill the array
strings = malloc (sizeof (char *)*4);
strings[0] = strdup ("h");
strings[1] = strdup ("a");
strings[2] = strdup ("f");
strings[3] = strdup ("d");

// Sort it
qsort (strings, sizeof (char *), 4, (void *)cmp_strptr);

BUGS
SEE ALSO
strcmp(), strncmp(), memcmp(), strcasecmp(), strncasecmp()
INTERNALS
HISTORY
01.01.1997 ldp
Removed double include files
11.12.1996 aros
Added/corrected headers
19.10.1996 aros
Moved all ANSI C function to here and wrote all neccessary header files. Now we have a real basis for our own C lib. Added the functions malloc(), free() and strcasecmp() Made all functions ANSI C compliant
21.09.1996 digulla
Use Amiga types Full ANSI prototypes
01.08.1996 digulla
Added standard header for all files
29.07.1996 digulla
Intermediate files until we can use libc for linking